package com.aixi.desktop

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.aixi.desktop.ui.LocalNavHostController
import com.aixi.desktop.ui.WidgetTimeConfig
import com.aixi.desktop.ui.theme.DesktopTheme
import com.aixi.desktop.utils.sendMyWidgetAppUpdate

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            DesktopTheme {
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    val controller = rememberNavController()
                    CompositionLocalProvider(LocalNavHostController provides controller) {
                        NavHost(navController = controller, "main") {
                            composable("main") {
                                Text(text = "AIXI", modifier = Modifier.clickable {
                                    controller.navigate("config_time_widget")
                                })
                            }
                            composable("config_time_widget") {
                                WidgetTimeConfig()
                            }
                        }
                    }
                }
            }
        }


        sendMyWidgetAppUpdate()
    }
}
